var a;
require("../util.js");
require("../component/components.js");
require("../../jsMt/util.js");
var vm = new Vue({
    el:"#recruitVideo",
    data:{
        isNav:1,
        isVideo:false,
        loadFlag:false,
        recruitId:"", //企业职位id
        loginUid:"",  //用户id
        recruitInfo:{}//视频信息
    },
    mounted:function(){
        this.searchObject = this.getQueryStringArgs();
        this.recruitId=this.searchObject&&this.searchObject.recruitId;
        this.loginUid=this.searchObject&&this.searchObject.uid;
        this.getRecruitInfo();
    },
    methods:{
        //后退
        getBack:function(){
            history.go(-1);
        },
        bgimg:function(url){
            url = url?url:"";
            return {
                "background-image":'url("'+url+'"),url("")'
            }
        },
        /*获取查询字符对象*/
        getQueryStringArgs: function () {
            //取得查询字符串并去掉开头的问号
            var qs = (location.search.length > 0 ? location.search.substring(1) : ""),
                args = {},
                items = qs.length ? qs.split("&") : [],
                item = null,
                name = null,
                value = null,
                len = items.length;
            for (var i = 0; i < len; i++) {
                item = items[i].split("=");
                name = item[0];
                value = item[1];
                if (name.length) {
                    args[name] = value;
                }
            }
            return args;
        },
        //招聘职位详情
        getRecruitInfo:function(){
            var that=this;
            var data={
                uid:that.loginUid,
                recruitId:that.recruitId
            };
            this.ajax({url:"/recruit/getRecruitInfo",data:data,dataType:"json",method:"post"},function(b){
                if(b.json.code==0&&b.json.data){
                    that.recruitInfo=b.json.data;
                    myPlayer.src(that.recruitInfo.imgSrc);
                    myPlayer.load();
                    myPlayer.play();
                }else{
                    vm.$refs.prompt.toast("获取招聘职位详情失败！")
                }
            });
        },
        //显示视频等图标
        getIsVideo:function(){
            this.isVideo=!this.isVideo;
        },
        //视频暂停
        getVideoPause:function(){
            console.log("1111111111"+this.curr);
            this.isNav=2;
            // clearInterval(a);
            myPlayer.pause();
        },
        //视频播放
        getVideoPlay:function(){
            this.isVideo=!this.isVideo;
            this.isNav=1;
            var whereYouAt = myPlayer.currentTime();
            myPlayer.currentTime(whereYouAt);
            myPlayer.play();
            // this.getCanvas();
        },
        getNext:function(){
            location.href="/see/companyInfo?uid="+this.loginUid+"&enterpriseId="+this.recruitInfo.enterpriseId;
        },
        //投递简历
        deliveryRecruitInfo:function(){
            var that=this;
            var data={
                // uid:that.loginUid,
                loginUid:7,
                recruitId:that.recruitId,
                enterpriseId:that.recruitInfo.enterpriseId
            };
            this.ajax({url:"/recruit/deliveryRecruitInfo",data:data,dataType:"json",method:"post"},function(b){
                if(b.json.code==0){
                    vm.$refs.prompt.toast("操作成功！")
                }else{
                    vm.$refs.prompt.toast(b.json.msg)
                }
            });
        }
    }
});
var myPlayer = videojs('my-video',{
    loop:true,
    // poster:vm.cityInfoById.officialCoverImgSrc,//预览图：string
    // autoplay:false,//自动播放：boolean
    controlBar: {
        //fullscreenToggle:false,
        volumeMenuButton:false
    }
});